#include <stdio.h>

int max(int a, int b) {
    return (a > b) ? a : b;
}

int main() {
    int n, k;
    scanf("%d", &n);
    scanf("%d", &k);

    int A[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    int dp[n+1];
    dp[0] = 0;
    dp[1] = A[0];

    for (int i = 2; i <= n; i++) {
        dp[i] = max(dp[i-1], dp[i-2] + A[i-1]);
    }

    int maxWater = dp[n];
    printf("%d\n", maxWater);

    return 0;
}
